import 'package:ecy_app_flutter/routes/my/model/order/UserOrderItem.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../ecycommon/EcyCommonWidgets.dart';
import 'EcyBuildRow.dart';
import '../../../EcyRouter.dart';

class EcyExchangeDetailPage extends EcyCommonBaseWidget {
  EcyExchangeDetailPage({required super.key});

  @override
  _EcyExchangeDetailPageState createState() => _EcyExchangeDetailPageState(this);
}

class _EcyExchangeDetailPageState extends EcyCommonBaseWidgetState {
  late EcyCommonBaseWidget controller;
  late UserOrderItem orderItem;
  _EcyExchangeDetailPageState(EcyCommonBaseWidget vc) {
    controller = vc;
  }


  @override
  void initState()  {
    super.initState();
    requestData();
  }

  @override
  Future<void> requestData({int pageIndex = 1, int type = 0}) async {
     orderItem = UserOrderItem();
     orderItem.commodityName = '咒术回战吧唧';
     orderItem.commoditySkuName = "咒术G款 五条; 85mm [银葱爆闪]";
     orderItem.commoditySkuNum = 1;
  }
  // FontWeight _fontWeightBold = FontWeight.w700;

  Padding waitCard() {
    return Padding(
      padding: const EdgeInsets.all(8),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.fromLTRB(16, 0, 0, 16),
            child: Row(
              children: [
                Text(
                  '商家审核',
                  style: TextStyle(
                    fontSize: 14.w,
                    fontFamily:  "PingFang SC",
                    fontWeight: orderItem.id == 1 ? FontWeight.w500 : FontWeight.w700,
                    color: const Color(0xFF000000)
                  )
                ),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                Text(
                  '寄回商品',
                  style: TextStyle(
                    fontSize: 14.w,
                    fontFamily:  "PingFang SC",
                    fontWeight: FontWeight.w500,
                    color: const Color(0xFF8C8C8C)
                  )
                ),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                Text(
                  '商家发货',
                  style: TextStyle(
                    fontSize: 14.w,
                    fontFamily:  "PingFang SC",
                    fontWeight: FontWeight.w500,
                    color: const Color(0xFF8C8C8C)
                  )
                ),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                Text(
                  '换货完成',
                  style: TextStyle(
                    fontSize: 14.w,
                    fontFamily:  "PingFang SC",
                    fontWeight: FontWeight.w500,
                    color: const Color(0xFF8C8C8C)
                  )
                ),
              ],
            ),
          ),
        ]
      )
    );
  }

  // // 弹出对话框
  // Future<bool?> showDeleteConfirmDialog(String content) {
  //   return showDialog<bool>(
  //     context: context,
  //     builder: (context) {
  //       return AlertDialog(
  //         // title: const Text(''),
  //         contentPadding: const EdgeInsets.all(0),
  //         backgroundColor: Colors.white,
  //         shape: RoundedRectangleBorder(
  //           borderRadius: BorderRadius.circular(8.0),
  //         ),
  //         content: SizedBox(
  //           height: 130,
  //           child: Column(
  //             mainAxisAlignment: MainAxisAlignment.center,
  //             children: [
  //               Padding(
  //                 padding: const EdgeInsets.only(top: 20, bottom: 30),
  //                 child: Text(
  //                   content,
  //                   style: TextStyle(fontSize: 18),
  //                 ),
  //               ),
  //               const Divider(height: 0, color: Color(0XFFdcdcdc)),
  //               SizedBox(
  //                 height: 50,
  //                 child: Row(
  //                   mainAxisAlignment: MainAxisAlignment.center,
  //                   crossAxisAlignment: CrossAxisAlignment.center,
  //                   children: <Widget>[
  //                     Expanded(
  //                       flex: 1,
  //                       child: DecoratedBox(
  //                         decoration: const BoxDecoration(
  //                             border: Border(
  //                               right: BorderSide(
  //                                 width: 1.0,
  //                                 color: Color(0XFFdcdcdc),
  //                               ),
  //                             )),
  //                         child: TextButton(
  //                           style: const ButtonStyle(
  //                             alignment: Alignment.center,
  //                           ),
  //                           child: const Text(
  //                             '取消',
  //                             style: TextStyle(
  //                                 fontSize: 18, color: Colors.black),
  //                           ),
  //                           onPressed: () =>
  //                               Navigator.of(context).pop(), // 关闭对话框
  //                         ),
  //                       ),
  //                     ),
  //                     Expanded(
  //                       flex: 1,
  //                       child: TextButton(
  //                         child: const Text(
  //                           '确认',
  //                           style: TextStyle(
  //                               fontSize: 18, color: Color(0xFFEA4B9B)),
  //                         ),
  //                         onPressed: () {
  //                           //关闭对话框并返回true
  //                           Navigator.of(context).pop(true);
  //                         },
  //                       ),
  //                     ),
  //                   ],
  //                 ),
  //               ),
  //             ],
  //           ),
  //         ),
  //         actionsAlignment: MainAxisAlignment.spaceAround,
  //         actionsPadding: const EdgeInsets.all(0),
  //       );
  //     },
  //   );
  // }

  @override
  Widget build(BuildContext context) {
    // Widget image = Image.asset('assets/images/erciyuan.jpg', width: 80);
    int? num = orderItem.commoditySkuNum;

    return Scaffold(
      backgroundColor: const Color(0xFFF5F5F5),
      appBar: AppBar(
        // backgroundColor: Colors.white,
        title: const Text('换货详情', style: TextStyle(fontSize: 18),),
        centerTitle: true,
        leading: GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
            EcyRouter.pop(context, "");
          },
          child: Align(
            alignment: Alignment.centerRight,
            child: Image.asset(
              "assets/images/ic_back.png",
              width: 30.w,
            ),
          ),
        ),
      ),
      bottomNavigationBar: Padding(
        padding: const EdgeInsets.fromLTRB(16, 10, 16, 20), // 底部安全距离
        child: Row(
          children: [
            Expanded(
              child: GestureDetector(
                onTap: () => print("取消"),
                child: Container(
                  height: 40.w,
                  // padding: EdgeInsets.symmetric(vertical: 14),
                  decoration: BoxDecoration(
                    color: Color(0xFFFF53A9).withOpacity(0.1),

                    borderRadius: BorderRadius.circular(30),
                  ),
                  alignment: Alignment.center,
                  child: const Text("撤销换货",
                  style: TextStyle(
                    fontFamily: "PingFang SC",
                    fontSize: 16,
                    fontWeight: FontWeight.w700,
                    color: Color(0xFFEA4B9B)
                    
                  ),),
                ),
              ),
            ),
            SizedBox(width: 16),
            Expanded(
              child: GestureDetector(
                onTap: () => print("提交"),
                child: Container(
                  height: 40.w,
                  // padding: EdgeInsets.symmetric(vertical: 14),
                  decoration: BoxDecoration(
                    color: Color(0xFFEA4B9B),
                    borderRadius: BorderRadius.circular(30),
                  ),
                  alignment: Alignment.center,
                  child: Text("修改申请",
                    style: TextStyle(
                        fontFamily: "PingFang SC",
                        fontSize: 16,
                        fontWeight: FontWeight.w700,
                        color: Color(0xFFFFFFFF)
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(8),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: const EdgeInsets.fromLTRB(16, 0, 0, 16),
                child: Row(
                  children: [
                    Text(
                        '商家审核',
                        style: TextStyle(
                            fontSize: 14.w,
                            fontFamily:  "PingFang SC",
                            fontWeight: FontWeight.w700,
                            color: const Color(0xFF000000)
                        )
                    ),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    Text(
                        '寄回商品',
                        style: TextStyle(
                            fontSize: 14.w,
                            fontFamily:  "PingFang SC",
                            fontWeight: FontWeight.w500,
                            color: const Color(0xFF8C8C8C)
                        )
                    ),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    Text(
                        '商家发货',
                        style: TextStyle(
                            fontSize: 14.w,
                            fontFamily:  "PingFang SC",
                            fontWeight: FontWeight.w500,
                            color: const Color(0xFF8C8C8C)
                        )
                    ),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    const Image(image: AssetImage('assets/images/Vector 28@2x.png')),
                    const Padding(padding: EdgeInsets.fromLTRB(14,0,0,0)),
                    Text(
                        '换货完成',
                        style: TextStyle(
                            fontSize: 14.w,
                            fontFamily:  "PingFang SC",
                            fontWeight: FontWeight.w500,
                            color: const Color(0xFF8C8C8C)
                        )
                    ),
                  ],
                ),
              ),

              const Padding(padding: EdgeInsets.only(bottom: 3)),
              Card(
                color: Colors.white,
                child: Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        '待商家审核',
                        // textAlign: TextAlign.start,
                        style: TextStyle(
                          fontFamily: "PingFang SC",
                          fontSize: 14.w,
                          color: const Color(0xFF262626),
                        ),
                      ),
                      const Padding(padding: EdgeInsets.all(3)),
                      RichText(
                          text: TextSpan(
                              children: [
                                TextSpan(
                                    text: '商家将在',
                                    style: TextStyle(
                                        fontSize: 12.w,
                                        fontWeight: FontWeight.w500,
                                        fontFamily:  "PingFang SC",
                                        color: const Color(0xFF8C8C8C)
                                    )
                                ),
                                TextSpan(
                                    text: '1天23小时',
                                    style: TextStyle(
                                        fontSize: 12.w,
                                        fontWeight: FontWeight.w700,
                                        fontFamily:  "PingFang SC",
                                        color: const Color(0xFF262626)
                                    )
                                ),
                                TextSpan(
                                    text: '内完成审核，截至2025-02-05 21:46:21未审核将自动通过申请',
                                    style: TextStyle(
                                        fontSize: 12.w,
                                        fontFamily:  "PingFang SC",
                                        fontWeight: FontWeight.w500,
                                        color: const Color(0xFF8C8C8C)
                                    )
                                ),
                              ]
                          )
                      ),
                      const Padding(padding: EdgeInsets.all(8)),
                      Row(
                        children: [
                          Text(
                            '寄件方式',
                            style: TextStyle(
                                fontSize: 12.w,
                                fontFamily:  "PingFang SC",
                                fontWeight: FontWeight.w500,
                                color: const Color(0xFF262626)
                            )
                          ),
                          const Padding(padding: EdgeInsets.fromLTRB(32, 0, 0, 0)),
                          Text(
                              '自行寄回',
                              style: TextStyle(
                                  fontSize: 12.w,
                                  fontFamily:  "PingFang SC",
                                  fontWeight: FontWeight.w500,
                                  color: const Color(0xFF262626)
                              )
                          ),
                        ],
                      )
                    ],
                  ),
                )
                
              ),
              Card(
                color: Colors.white,
                child: Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                          '协商历史',
                          style: TextStyle(
                              fontSize: 14.w,
                              fontFamily:  "PingFang SC",
                              fontWeight: FontWeight.w700,
                              color: const Color(0xFF262626)
                          )
                      ),
                      Image(image: AssetImage('assets/images/rightArrow.png'),height: 12.w,)
                    ],
                  )
                )
              ),
            Card(
              color: Colors.white,
              child: Padding(
                  padding: const EdgeInsets.all(16.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    RichText(text: TextSpan(
                      children: [
                        TextSpan(
                          text: '换货信息',
                          style: TextStyle(
                              fontSize: 14.w,
                              fontFamily:  "PingFang SC",
                              fontWeight: FontWeight.w700,
                              color: const Color(0xFF262626)
                          ),
                        ),
                        TextSpan(text: '  '),
                        TextSpan(
                          text: '(共$num件)',
                          style: TextStyle(
                              fontSize: 14.w,
                              fontFamily:  "PingFang SC",
                              fontWeight: FontWeight.w500,
                              color: const Color(0xFF8C8C8C)
                          ),

                        ),
                      ]
                    )),
                    const Padding(padding: EdgeInsets.all(8)),
                    BuildRow(orderItem: orderItem),
                  ],
                )
              ),

            ),

            ],
          ),
        ),
      ),

    );
  }

}
